/*
    simplecookbook  -  simplecookbook.database.DataBase.java
                             -------------------
    begin                : 08/10/2008
    copyright            : (C) 2008 by cristovao
    email                : cristovao.wollieson@gmail.com
 ***************************************************************************/

/*
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful, but   *
 *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
 *   General Public License for more details.                              *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,   *
 *   MA  02111-1307 USA                                                    *
 ***************************************************************************/

/**
 * Pacote responsavel por controla o banco de dados
 * 
 * @author cristovao
 */
package org.ybacoby.simplecookbook.database;

import java.sql.ResultSet;

import org.ybacoby.simplecookbook.exception.SimpleCookBookException;



/**
 * @author cristovao
 *
 */
public class DataBase  implements IDataBase {

	/**
	 * O banco de dados a ser utilizado
	 */
	private IDataBase database;
	
	/**
	 * Constructor
	 * 
	 * @param database
	 */
	public DataBase(IDataBase database) {
		this.database = database;
	}

	/**
	 * @see org.ybacoby.simplecookbook.database.IDataBase#closerDataBase()
	 */
	public void closerDataBase() throws SimpleCookBookException {
		this.database.closerDataBase();
		
	}

	/**
	 * @see org.ybacoby.simplecookbook.database.IDataBase#connectDataBase()
	 */
	public void connectDataBase() throws SimpleCookBookException {
		this.database.connectDataBase();
		
	}

	/**
	 * @see org.ybacoby.simplecookbook.database.IDataBase#insertSqlDatabase(String)
	 */
	public void insertSqlDatabase(String sql) throws SimpleCookBookException {
		// Validando a String
		if (sql.equals(null)) throw new SimpleCookBookException();
		
		this.database.insertSqlDatabase(sql);
		
	}

	/**
	 * @see org.ybacoby.simplecookbook.database.IDataBase#selectSqlDatabase(String)
	 */
	public ResultSet selectSqlDatabase(String sql) throws SimpleCookBookException {
		// Validando a String
		if (sql.equals(null)) throw new SimpleCookBookException();
		
		return this.database.selectSqlDatabase(sql);
	}

	/**
	 * @see org.ybacoby.simplecookbook.database.IDataBase#sqlDataTime()
	 */
	public String sqlDataTime() throws SimpleCookBookException {
		return this.database.sqlDataTime();
	}

	/**
	 * @see org.ybacoby.simplecookbook.database.IDataBase#totalItensDataSql(EnumTabelaDataBase)
	 */
	public int totalItensDataSql(EnumTabelaDataBase tabela)
			throws SimpleCookBookException {
		
		// Validando a String
		if (tabela.equals(null)) throw new SimpleCookBookException();
		
		return this.database.totalItensDataSql(tabela);
	}

}
